#!/bin/bash
#
# Init script for PacketFence remote arp sensor
#
# chkconfig: - 35 65
# description: PacketFence remote ARP sensor
#
# processname: 
# config: /usr/local/pf/conf/pfarp_remote.conf

### BEGIN INIT INFO
# Provides: pfarp
# Required-Start: $memcached 
# Required-Stop: 
# Should-Start: $memcached
# Should-Stop: 
# Default-Start: 
# Default-Stop: 
# Short-Description: Sniff arp request and send to packetfence
# Description: PacketFence remote arp sensor
### END INIT INFO


. /etc/rc.d/init.d/functions

prog="/usr/local/pf/sbin/pfarp_remote"
prog_base="$(basename ${prog})"

RETVAL=0

start() {
	echo -n $"Starting ${prog_base}: "
	if [ -f /usr/local/pf/var/run/pfarp_remote.pid ]; then
		echo -n $"${prog_base}: already running"
		echo
		return 0
	fi
	daemon ${prog} -d -i eth1
	RETVAL=$?
	echo
	return $RETVAL
}

stop() {
	echo -n $"Shutting down ${prog_base}:"
	killproc ${prog_base}
	RETVAL=$?
	echo
	return $RETVAL
}

restart() {
	stop
	start
}

case "$1" in
  start)
	start
	RETVAL=$?
	;;
  stop)
	stop
	RETVAL=$?
	;;
  status)
	status ${prog_base}
	RETVAL=$?
	;;
  restart)
        restart
	RETVAL=$?
	;;
  *)
	echo $"Usage: $0 {start|stop|restart|status}"
	RETVAL=1
esac

exit $RETVAL
